import 'package:flutter/material.dart';
import 'package:gold/route/routes.dart';
import 'package:gold/route/xfg_nav.dart';
import 'package:gold/utils/res.dart';
import 'package:gold/utils/xfg_color.dart';
import 'package:gold/utils/xfg_size.dart';
import 'package:gold/widgets/common_widgets.dart';
import 'package:gold/widgets/xfg_text.dart';

/// @description: 支付成功页面
/// @author tangzhentao
/// @created at 01:26 2025/2/16

class PaySuccessPage extends StatelessWidget {
  /// 订单id
  final int id;
  /// 订单类型 商品，黄金投资，积分
  final String type;
  /// 是否来自订单
  final bool fromOrder;

  const PaySuccessPage({super.key, required this.type, required this.id, this.fromOrder = false});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: xfgAppbar(title: '支付结果'),
      body: Column(
        children: [
          SizedBox(height: XfgSize().size128, width: XfgSize().screenWidth),
          Image.asset(Res.imagesWithdrawalSuccess, width: XfgSize().size60, height:  XfgSize().size60),
          SizedBox(height: XfgSize().size34),
          XfgText('支付成功', fontSize: XfgSize().text18, color: XfgColor.text1D),
          SizedBox(height: XfgSize().size16),
          XfgText('可以在个人中心"我的订单"查看', fontSize: XfgSize().text14, color: XfgColor.colorB5),
          SizedBox(height: XfgSize().size97),
          TextButton(
              onPressed: () => XfgNav.pushNamed(Routes.myOrderDetail, arguments: {'orderType': type, 'orderId': id}),
              style: xfgButtonStyle(Size(XfgSize().size200, XfgSize().size50), radius: XfgSize().size50),
              child: XfgText('查看订单', fontSize: XfgSize().text18, color: XfgColor.white, bold: FontWeight.bold)
          ),
          SizedBox(height: XfgSize().size20),
          TextButton(
              onPressed: () {
                if (fromOrder) {
                  XfgNav.pop();
                } else {
                  XfgNav.popUntil(Routes.root);
                }
              },
              style: xfgButtonStyle(Size(XfgSize().size200, XfgSize().size50),
                  color: XfgColor.transparent,
                  radius: XfgSize().size50,
                  side: BorderSide(color: XfgColor.colorB8, width: XfgSize().size0_5)
              ),
              child: XfgText('返回${fromOrder ? '订单列表':'首页'}', fontSize: XfgSize().text18, color: XfgColor.text2)
          ),
        ],
      ),
    );
  }

}
